** "The Policy Substance of Legislative Ideology"
** Legislators Code **

** Open Legislators Data
use "C:\Users\Adam\Dropbox\Policy Tools\Paper Text\Replication Files\Legislators Data.dta"


** The key to cosposorship variable names is as follows:
* All varibles being with pct_maj
* "lib" means "increasing" instrument, "con" means decreasing instrument.
* "r" = resources, "a" = authority/rules, "i" = information/communication
* The numbers are Comparative Agendas Project major topics, but in consecutive order, NOT major topic codes.
   *  1 = macroeconomics, 2 = civil rights/liberties, 3 = health, 4 = agriculture
   *  5 = labor, 6  = educatin, 7 = environment, 8 = energy, 9 = transportation, 10 = law, crime, family
   *  11 = welfare, 12 = community development, 13 = banking and finance, 14 = defense
   *  15 = science, 16 = trade, 17 = international affairs, 18 = government operations, 19 = public land and water
   * NOTE: Three key exceptions - pct_majconi17 refers to government operatiosn, pct_majconi18 refers to public land and water
   *       There are no international affairs bills decreasing information.

* Figure 4
factor pct_majlibr1-pct_majconi18, factors(25)
screeplot, ylab(0(1)10) scheme(plotplain) xtitle("Factor Number") ytitle("Eigenvalues")

* Table 2
factor pct_majlibr1-pct_majconi18, factors(4)
rotate, oblimin factors(4)
predict fr1 fr2 fr3 fr4

* Figure 5
lowess fr1 dwnom1 if congress==111, note("R = 0.88")xtitle("First Dimension DW-NOMINATE") ytitle("Factor Score") title("Factor 1") scheme(plotplain) name(f1)
lowess fr2 dwnom1 if congress==111, note("R = -0.72")xtitle("First Dimension DW-NOMINATE") ytitle("Factor Score") title("Factor 2") scheme(plotplain) name(f2)
gr combine f1 f2

* Figure 6
reg fr1 i.con_faction i.congress, cluster(icpsrid)
quietly: margins, at(con_faction = (0 1 2 3 4 5))
marginsplot, scheme(plotplain) name(substance) title("Factor 1")

reg dwnom1 i.con_faction i.congress, cluster(icpsrid)
quietly: margins, at(con_faction = (0 1 2 3 4 5))
marginsplot, scheme(plotplain) name(nominate) title("NOMINATE")

reg cfscore i.con_faction i.congress, cluster(icpsrid)
quietly: margins, at(con_faction = (0 1 2 3 4 5))
marginsplot, scheme(plotplain) name(cfscore) title("CF Score")

gr combine substance nominate cfscore, col(3) // set aspect ratio to 1



